public class AsteriskDiamond {

    public void drawAHorizontalLine(int n, char c) {
        for (int i = 0; i < n; i++) {
            System.out.print(c);
        }
    }

    public void printIsoscelesTriangle(int n, int bias) {  //等腰三角形，定义了初始的偏移量
        for (int i = 1; i <= n; i++) {
            drawAHorizontalLine(n-i+bias, ' ');
            drawAHorizontalLine(2*i-1, '*');
            drawAHorizontalLine(n-i+bias, ' ');
            System.out.println("\n");
        }
    }

    public void printInvertedIsoscelesTriangle(int n, int bias) {   //倒立的等腰三角形，定义了初始的偏移量
        for (int i = n; i >= 1; i--) {
            drawAHorizontalLine(n-i+bias, ' ');
            drawAHorizontalLine(2*i-1, '*');
            drawAHorizontalLine(n-i+bias, ' ');
            System.out.println("\n");
        }
    }

    public void printDiamond(int n) {
        printIsoscelesTriangle(n,0);
        printInvertedIsoscelesTriangle(n-1,1);
    }

    public void printDiamondWithName (String name, int n) {
        printIsoscelesTriangle(n-1, 1);
        System.out.println(name);
        printInvertedIsoscelesTriangle(n-1, 1);
    }
}
